/**
 * 弹出框封装类
 * msg:要提示的消息内容
 * autoClosed:弹出后，是否自动关闭
 * @type {{}}
 */
var MsgAlert = {};
MsgAlert.warn = function(msg,autoClosed){
    _msg_do_close_clear();
    $("body").prepend("<div id='warningAlert' class='alert alert-warning'>" +
        "<a href='#' class='close' data-dismiss='alert'>&times;</a><strong>提示：</strong><span id='_dynamicGeneration_msg'></span></div>");
    $("#_dynamicGeneration_msg").html(msg);
    $("#warningAlert").attr("style","display:none;margin:auto;position:fixed;width: 40%;z-index: 1051;left:0;right:0;");
    $("#warningAlert").slideToggle("fast",function(){
        if(autoClosed==true){
            setTimeout("_msg_do_close_clear()",1500);
        }
    });
};
function _msg_do_close_clear(){
    $("#successAlter").slideToggle("fast",function(){$("#successAlter").remove()});
    $("#warningAlert").slideToggle("fast",function(){$("#warningAlert").remove()});
}
MsgAlert.info = function(msg,autoClosed){
    _msg_do_close_clear();
    $("body").prepend("<div id='successAlter' class='alert alert-success'>" +
        "<a href='#' class='close' data-dismiss='alert'>&times;</a><strong>提示：</strong><span id='_dynamicGeneration_msg'></span></div>");
    $("#_dynamicGeneration_msg").html(msg);
    $("#successAlter").attr("style","display:none;margin:auto;position:fixed;width: 40%;z-index: 1051;left:0;right:0;");
    $("#successAlter").slideToggle("fast",function(){
        if(autoClosed==true){
            setTimeout("_msg_do_close_clear()",1500);
        }
    });
};


/**
 * @param callback 点击确定时要执行的回调函数
 */
MsgAlert.confirm = function (msg,callback,btnShow) {
    if ($("#_myConfirm").length > 0) {
        $("#_myConfirm").remove();
    }
    if(btnShow == true){
        btnShow = "";
    }else{
        btnShow = "display:none;";
    }
    var html = "<div class='modal fade' id='_myConfirm' >"
        + "<div class='modal-backdrop in' style='opacity:0; '></div>"
        + "<div class='modal-dialog' style='z-index:2901; margin-top:60px; width:400px; '>"
        + "<div class='modal-content'>"
        + "<div class='modal-header'  style='font-size:16px; '>"
        + "<span class='glyphicon glyphicon-envelope'>&nbsp;</span>提示：<button type='button' class='close' data-dismiss='modal'>"
        + "<span style='font-size:20px;  ' class='glyphicon glyphicon-remove'></span><tton></div>"
        + "<div class='modal-body text-center' id='yn_confirm_content_' style='font-size:18px; '>"
        + msg
        + "</div>"
        + "<div class='modal-footer ' style='"+btnShow+"'>"
        + "<button class='btn btn-danger ' id='confirmOk' >确定<tton>"
        + "<button class='btn btn-info ' data-dismiss='modal'>取消<tton>"
        + "</div>" + "</div></div></div>";
    $("body").append(html);
    console.log($("#_myConfirm"));
    $("#_myConfirm").modal("show");

    $("#confirmOk").on("click", function() {
        $("#_myConfirm").modal("hide");
        callback(); // 执行函数
    });
}